﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DCMS_Framework {
  [Serializable]
  public class BusinessBase {

    private BrokenBusinessRules brokenRules = new BrokenBusinessRules( );

    public BrokenBusinessRules BrokenRules {
      get { return brokenRules; }
      //set { brokenRules = value; }
    }

    public bool IsValid {
      get {
        return brokenRules.Count == 0;
      }
    }

    public string BrokenRulesMessages {
      get {
        StringBuilder sb = new StringBuilder( );
        foreach ( BusinessRule rule in brokenRules ) {
          sb.Append( rule.Description + "\n" );
        }
        return sb.ToString( );
      }
    }

    public void AddBrokenRule( string name, string description ) {
      BusinessRule rule = new BusinessRule( name, description );
      brokenRules.Add( rule );
    }

    public void AddBrokenRule( string name, string description, string property ) {
      BusinessRule rule = new BusinessRule( name, description, property );
      brokenRules.Add( rule );
    }

    public void ClearBrokenRules( ) {
      brokenRules.Clear( );
    }

  }
}
